package com.example;

//Rest模式


import com.MyDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/books")
public class BookController {
    //数据的读取
    @Value("${likes[1]}")
    private String like;

    @Value("${tempDir}")
    private String tempDir;

    //使用自动装配将所有的数据封装到一个对象Environment中
    @Autowired
    private Environment env;

    //使用自动装配 把需要的数据封装在一个类里面
    @Autowired
    private MyDataSource myDataSource;


   @GetMapping(value = "/{id}")
    public String getById(@PathVariable Integer id){
       System.out.println(myDataSource);
       System.out.println(env.getProperty("enterprise.sbugetc[1]"));
        System.out.println(id);
       System.out.println(tempDir);
        System.out.println("springboot is runing...");
        return "springboot is running..";
    }

}
